#include "mapplacesearchwid.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "PlaceManger.h"

MapPlaceSearchWid::MapPlaceSearchWid(QWidget *parent) : QWidget(parent)
{
    resize(600,50);
    QHBoxLayout *hlayout = new QHBoxLayout(this);
//    QVBoxLayout *vlayout = new QVBoxLayout(this);
    //this->nameEdit = new QLineEdit(this);
    this->nameBox = new QComboBox(this);
    this->nameLab = new QLabel("请选择您要查询的地点：",this);
    this->btn = new QPushButton("查找",this);

    hlayout->addWidget(nameLab);
    hlayout->addWidget(nameBox);
    hlayout->addWidget(btn);
    this->btn->setMaximumWidth(600);
    this->nameBoxInit();
}

void MapPlaceSearchWid::nameBoxInit()
{
    PlaceManger PM;
    int sum = 0;
    Place *places = PM.List(sum);
    for(int i = 0;i<sum;i++)
    {
        if(strcmp(places[i].getName(),"")!=0)
            this->nameBox->addItem(places[i].getName());
    }
}

QComboBox *MapPlaceSearchWid::getNameComBox()
{
    return this->nameBox;
}
